package org.kessy.common.model.meta;

import java.util.ArrayList;
import java.util.Collection;

/***
 * 
 * @author leo.liu
 * Meta Attribute, represent the attribute of entity
 */
public class MAttribute extends MBase{

    /**
     * 
     */
    private static final long serialVersionUID = 8118859317340035L;

    public static final String DATATYPE_STRING = "String";
    public static final String DATATYPE_BOOLEAN = "Boolean";
    public static final String DATATYPE_NUMBER = "Number";
    public static final String DATATYPE_DOUBLE = "Double";
    public static final String DATATYPE_DATE = "Date";
    public static final String DATATYPE_PASSWORD = "Password";
    public static final String DATATYPE_SINGLE_DICTIONARY = "SingleDictionary";
    
    private String name;
    private String label;
    private String dataType;
    private String fieldName;
    private Long orderNum;
    
    private Collection<MDictionary> dictionarys;
    private MEntity entity;
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getLabel() {
        return label;
    }
    
    public void setLabel(String label) {
        this.label = label;
    }
    
    public String getDataType() {
        return dataType;
    }
    
    public void setDataType(String dataType) {
        this.dataType = dataType;
    }
    
    public String getFieldName() {
        return fieldName;
    }
    
    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }
    
    public Long getOrderNum() {
        return orderNum;
    }
    
    public void setOrderNum(Long orderNum) {
        this.orderNum = orderNum;
    }
    
    public Collection<MDictionary> getDictionarys() {
        return dictionarys;
    }
    
    public void setDictionarys(Collection<MDictionary> dictionarys) {
        this.dictionarys = dictionarys;
    }
    
    public void addDictionary(MDictionary _mDictionary){
        if(_mDictionary == null)
            return;
        
        if(dictionarys == null)
            dictionarys = new ArrayList<MDictionary>();
        
        dictionarys.add(_mDictionary);
    }
    
    public void removeDictionary(MDictionary _mDictionary){
        if(_mDictionary == null)
            return;
        
        if(dictionarys != null)
            dictionarys.remove(_mDictionary);
    }
    
    public MEntity getEntity() {
        return entity;
    }
    
    public void setEntity(MEntity entity) {
        this.entity = entity;
    }
    
    @Override
    public void copyShallow(MBase mBase) {
        super.copyShallow(mBase);
        
        MAttribute mAttribute = (MAttribute)mBase;
        
        this.name = mAttribute.getName();
        this.label = mAttribute.getLabel();
        this.dataType = mAttribute.getDataType();
        this.fieldName = mAttribute.getFieldName();
        this.orderNum = mAttribute.getOrderNum();
    }
}
